<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-baseInfo-edit" th:object="${baseInfo}">
            <input id="empId" name="empId" th:field="*{empId}"  type="hidden">
            <div class="form-group">	
                <label class="col-sm-3 control-label">姓名：</label>
                <div class="col-sm-8">
                    <input id="empNm" name="empNm" th:field="*{empNm}" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">证件类型：</label>
                <div class="col-sm-8">
					<!--<select id="empIdType" class="form-control m-b" th:with="type=${@dict.getType('pm_card_type')}" >-->
	                    <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{empIdType}"></option>-->
	                <!--</select>-->
                    <input id="empIdType" name="empIdType" th:field="*{empIdType}" class="form-control" type="text" readonly="readonly">
				</div>
            </div>
            <div class="form-group">	
				<label class="col-sm-3 control-label">证件号码：</label>
				<div class="col-sm-8">
					<input id="empId" name="empId" th:field="*{empId}" class="form-control" type="text" readonly="readonly">
				</div>
			</div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">手机号码：</label>
                <div class="col-sm-8">
                    <input id="empTel" name="empTel" th:field="*{empTel}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
				<label class="col-sm-3 control-label">性别：</label>
				<div class="col-sm-8">
					<select id="empSex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{empSex}"></option>
	                </select>
				</div>
			</div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">所属公司名称：</label>
                <div class="col-sm-8">
                    <input id="empComp" name="empComp" th:field="*{empComp}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">人员技能及特长：</label>
                <div class="col-sm-8">
                    <textarea type="text" id="empSkills" name="empSkills" th:field="*{empSkills}" class="form-control" rows="10"></textarea>
                </div>
            </div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "pm/baseInfo";
		
		$("#form-baseInfo-edit").validate({
			rules:{
				empId:{
        			required:true
        		},
        		empNm:{
        			required:true
        		},
        		empTel:{
        			required:true,
                    isPhone:true
        		},
        		// empIdType:{
        		// 	required:true
        		// },
        		empComp:{
        			required:true
        		},
        	},
        	messages: {
                "empId": {
                    remote: "证件号码已经存在"
                }
            }
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            //$.operate.save(prefix + "/edit", $('#form-baseInfo-edit').serialize());
	            edit();
	        }
	    }
		
		function edit() {
        	var empId = $("input[name='empId']").val();
        	var empNm = $("input[name='empNm']").val();
        	var empTel = $("input[name='empTel']").val();
        	var empIdType = $("#empIdType option:selected").val();
        	var empSex = $("#empSex option:selected").val();
        	var empComp = $("input[name='empComp']").val();
        	var empSkills = $("textarea[name='empSkills']").val();
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "pm/baseInfo/edit",
        		data : {
        			"empId": empId,
        			"empNm": empNm,
        			"empTel": empTel,
        			"empIdType": empIdType,
        			"empSex": empSex,
        			"empComp": empComp,
        			"empSkills": empSkills
        		},
        		async : true,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }
	</script>
</body>
</html>
